<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <script src="../js/dayjs.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root">
        <h3>现在是：{{time | timeFormater('YYYY_MM_DD') | mysplic}}</h3>
    </div>
</body>
<script>
    Vue.config.productionTip = false
    //全局过滤器
    Vue.filter('mySlice', function (value) {
        return value.slice(0, 4)
    })
    const vm = new Vue({
        el: '#root',
        data: {
            time: new Date()
        },
        filters: {
            timeForMater(value, Str = 'YYYY-MM-DD HH:mm:ss') {
                //console.log(JSON.stringify(this.userInfo)
                return dayjs(value).format(str)
            },
            mysplice(value) {
                return value.slice(0, 4)
            }
        },
    })
</script>

</html>